package com.xinruke.hostels.central.manage.controller;

import com.xinruke.hostels.common.controller.BaseController;
import com.xinruke.hostels.common.vo.ResultVO;
import com.xinruke.hostels.common.vo.query.RowsDataVO;
import com.xinruke.hostels.reservation.user.interfaces.api.ReservationUserApi;
import com.xinruke.hostels.reservation.user.interfaces.dto.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author ChenXiangpeng
 * @ClassName MemberManageController
 * @date：2019/7/26
 * @version: V1.0.0
 * @description：会员管理
 */
@RestController
@RequestMapping("/memberManager")
@Api(tags = "会员管理")
public class MemberManageController extends BaseController {
    @Autowired
    private ReservationUserApi reservationUserApi;

    @PostMapping("/member/list")
    @ApiOperation("查询会员列表")
    ResultVO<RowsDataVO<MemberDetailQuertResultDTO>> memberList(@Valid @RequestBody MemberListQueryDTO memberListQueryDTO) {
        ResultVO<RowsDataVO<MemberDetailQuertResultDTO>> rowsDataVOResultVO = reservationUserApi.memberList(memberListQueryDTO);
        return rowsDataVOResultVO;
    }

    @PostMapping("/member/detail")
    @ApiOperation("查询会员信息")
    ResultVO<MemberDetailQuertResultDTO> detailById(@Valid @RequestBody MemberDetailQueryByIdDTO memberDetailQueryByIdDTO) {
        ResultVO<MemberDetailQuertResultDTO> resultVO = reservationUserApi.detailById(memberDetailQueryByIdDTO);
        return resultVO;
    }

    @PostMapping("/relatives/list")
    @ApiOperation("查询会员亲属列表")
    ResultVO<RowsDataVO<ContactsInfo>> relativesList(@Valid @RequestBody ContactsListQueryDTO contactsListQueryDto) {
        return reservationUserApi.contactsListInnerAPI(contactsListQueryDto);
    }

    @PostMapping("/relatives/detail")
    @ApiOperation("查询会员亲属信息")
    ResultVO<ContactsDetailResultDto> relativesDetail(@Valid @RequestBody ContactsDetailQueryDTO queryDTO) {
        return reservationUserApi.contactDetailInnerAPI(queryDTO);
    }

    @PostMapping("/member/add")
    @ApiOperation("新增会员信息")
    ResultVO addMember(@Valid @RequestBody MemberAddDTO memberAddDTO) {
        ResultVO resultVO = reservationUserApi.addMember(memberAddDTO);
        return resultVO;
    }

}
